<template>
  <el-col>
    <el-menu 
      active-text-color="#ffd04b"
      background-color="#545c64"
      class="el-menu-vertical-demo"
      default-active="2"
      text-color="#fff"
      @open="handleOpen"
      @close="handleClose">
      <el-sub-menu @click="selectMenu(item.path)" v-for="(item,index) in data" :key="index" :index="item.path">
        <template #title>
              <el-icon>
                <component :is="item.icon"></component>
              </el-icon>{{item.name}}
        </template>
        <div v-if="item.children">
          <div v-if="item.children.length > 1">
            <el-menu-item-group>
              <NavigationItem v-if="item.children" :data="item.children"></NavigationItem>
            </el-menu-item-group>
          </div>
          <div v-else>
            <NavigationItem v-if="item.children" :data="item.children"></NavigationItem>
          </div>
        </div>
      </el-sub-menu>
    </el-menu>
  </el-col>

</template>
<script>
export default {
  name: 'NavigationItem',
  props: ['data'],
  methods: {
    showhd (id, e) {
      const dom = e.target.nextElementSibling
      if (dom.className === 'show') {
        dom.className = 'head'
      } else {
        dom.className = 'show'
      }
    },
    selectMenu: function(name) {
       this.sidebarItem = name;
      this.$router.push({
        name: name,
      });
    }
  }
 
}
</script>